#@adminLayout()
#define main()
<div class="card">
    <div class="card">
        <div class="card-header">
            <h2 class="card-title">代码生成管理</h2>
            <div class="progress">
                <div class="progress-bar bg-success" role="progressbar" style="width: 100%" aria-valuenow="100"
                     aria-valuemin="0"
                     aria-valuemax="100"></div>
            </div>
        </div>

        <div class="card-block">
            <div class="tab-container">
                <ul class="nav nav-tabs nav-fill" role="tablist">
                    <li class="nav-item">
                        <a class="nav-link active" data-toggle="tab" href="#genModel" role="tab">实体生成</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href="#genCode" role="tab">代码生成</a>
                    </li>
                </ul>

                <div class="tab-content">
                    <div class="tab-pane active fade show" id="genModel" role="tabpanel">
                        <button class="btn btn-secondary btn--icon-text waves-effect" id="gen_model"><i
                                class="zmdi zmdi-check"></i>
                            实体生成
                        </button>
                    </div>
                    <div class="tab-pane fade" id="genCode" role="tabpanel">
                        <div class="card">
                            <div class="card-header">
                                <h2 class="card-title">选择生成</h2>
                            </div>
                            <div class="card-block">
                                <form action="/admin/sys/gen/genCode" id="jmisForm" method="post">
                                    <div class="row">
                                        <div class="col-sm-4">
                                            <label>所属项目</label><br/><br/>
                                            <div class="form-group">
                                                <select class="select2" name="srcFolder" onchange="opt(this.value)">
                                                    <option>&nbsp;</option>
                                                    #for(x:taxList)
                                                    <option value="#(x.identification)">#(x.name)</option>
                                                    #end
                                                </select>
                                            </div>
                                        </div>

                                        <div class="col-sm-4" id="ktablelist">
                                            <label>数据表</label><br/><br/>
                                            <div class="form-group">
                                                <select class="select2" name="tableName" id="ktablelists">
                                                    <option>&nbsp;</option>
                                                    #for(x:talbeList)
                                                    <option value="#(x.TABLE_NAME)-#(x.TABLE_COMMENT)">#(x.TABLE_COMMENT)</option>
                                                    #end
                                                </select>
                                            </div>
                                        </div>

                                        <div class="col-sm-12">
                                            <label>自定义分页sql</label>
                                            <div class="form-group">
                                            <textarea class="form-control" name="sqlPage" rows="7"
                                                      placeholder='自己的sql语句：select * from test'></textarea>
                                                <i class="form-group__bar"></i>
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <button type="submit" class="btn btn-secondary btn--icon-text waves-effect">
                                                <i
                                                        class="zmdi zmdi-check"></i> 生成
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function opt(result){
        $.post("/admin/sys/gen/opt",{"ide":result},function (ret) {
            if (ret.state=='ok'){
                $("#ktablelist").show();
                var html="";
                $.each(ret.data, function(i,v){
                    html+="<option></option><option value='"+v.table_name+"-"+v.table_comment+"'>"+v.table_comment+"</option>";
                });
                $('#ktablelists').html(html);
            }
        })
    }

    $("#gen_model").click(function () {
        console.info("实体生成");
        $.post("/admin/sys/gen/genModel", function (ret) {
            showMsg(0, ret.msg);
        })
    })

    $(document).ready(function () {
        $("#jmisForm").ajaxForm({
            dataType: "json"
            , beforeSubmit: function (formData, jqForm, options) {
            }
            , success: function (ret) {
                if (ret.state == "ok") {
                    showMsg(0, ret.msg);
                    //$.pjax({url: "/admin/sys/gen", container: '#pjax-container'});
                } else {
                    showMsg(3, ret.msg)
                }
            }
            , error: function (ret) {
                showMsg(3, ret.statusText)
            }
            , complete: function (ret) {
            }
        });

        $("#ktablelist").hide();

    });

    if ($("select.select2")[0]) {
        var a = $(".select2-parent")[0] ? $(".select2-parent") : $("body");
        $("select.select2").select2({
            dropdownAutoWidth: !0,
            width: "100%",
            dropdownParent: a
        })
    }
</script>
#end